package com.spring.component.test.proxy;

import java.lang.reflect.Proxy;

/**
 * @ClassName: WorkerProxy
 * @Description:
 * @author: liushihua
 * @date: 2018/12/28
 **/
public class WorkerProxy {

  /**
   * 获得代理对象
   * 
   * @param worker 被代理的目标对象
   * @return
   */
  public static Worker proxy(Worker worker) {
    Class clazz = worker.getClass();
    Worker proxy = (Worker) Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(),
        new ProxyHandler(worker));
    return proxy;
  }
}
